package com.bw.zg3park2212.apply

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.facade.annotation.Route
import com.bw.base.mvvm.BaseActivity
import com.bw.base.mvvm.BaseViewActivity
import com.bw.zg3park2212.R
import com.bw.zg3park2212.databinding.ActivityApplyBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/app/ApplyActivity")
class ApplyActivity : BaseActivity<ActivityApplyBinding,ApplyViewModel>() {
    lateinit var parkApplyAdpter: ParkApplyAdpter
    lateinit var repairApplyAdpter: RepairApplyAdpter
    lateinit var orderApplyAdpter: OrderApplyAdpter
    lateinit var insApdpter: InsApdpter
    override fun intitView() {
        parkApplyAdpter= ParkApplyAdpter()
        repairApplyAdpter= RepairApplyAdpter()
        orderApplyAdpter= OrderApplyAdpter()
        insApdpter= InsApdpter()
        binding.rv.adapter=parkApplyAdpter
        binding.rv.layoutManager= LinearLayoutManager(this)
        binding.rv.addItemDecoration(DividerItemDecoration(this,RecyclerView.VERTICAL))
        viewmodel.parkApply(1)
        binding.cwsq.setOnClickListener {
            binding.rv.adapter=parkApplyAdpter
            viewmodel.parkApply(1)
        }
        binding.lfsq.setOnClickListener {
            binding.rv.adapter=repairApplyAdpter
            viewmodel.repairApply()
        }
        binding.bxsq.setOnClickListener {
            binding.rv.adapter=orderApplyAdpter
            viewmodel.repair()
        }
        binding.xgsq.setOnClickListener {
            binding.rv.adapter=insApdpter
            viewmodel.getorder()
        }
    }

    override fun intitData() {
        viewmodel.parkapplySuccse.observe(this){
            parkApplyAdpter.data.clear()
            parkApplyAdpter.addData(it)
            parkApplyAdpter.notifyDataSetChanged()
        }
        viewmodel.repairapplySuccse.observe(this){
            repairApplyAdpter.data.clear()
            repairApplyAdpter.addData(it)
            repairApplyAdpter.notifyDataSetChanged()
        }
        viewmodel.repairSuccse.observe(this){
            orderApplyAdpter.data.clear()
            orderApplyAdpter.addData(it)
            orderApplyAdpter.notifyDataSetChanged()
        }
        viewmodel.orderSucsse.observe(this){
            insApdpter.data.clear()
            insApdpter.addData(it)
            insApdpter.notifyDataSetChanged()
        }
    }

}